define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'resume/index' + location.search,
                    add_url: 'resume/add',
                    edit_url: 'resume/edit',
                    del_url: 'resume/del',
                    multi_url: 'resume/multi',
                    import_url: 'resume/import',
                    table: 'resume',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'name', title: __('Name'), operate: 'LIKE'},
                        {field: 'sex', title: __('Sex'), operate: 'LIKE'},
                        {field: 'height', title: __('Height'), operate: 'LIKE'},
                        {field: 'weight', title: __('Weight'), operate: 'LIKE'},
                        {field: 'birthday', title: __('Birthday'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'political', title: __('Political'), operate: 'LIKE'},
                        {field: 'nation', title: __('Nation'), operate: 'LIKE'},
                        {field: 'place', title: __('Place'), operate: 'LIKE'},
                        {field: 'telephone', title: __('Telephone'), operate: 'LIKE'},
                        {field: 'ufather', title: __('Ufather'), operate: 'LIKE'},
                        {field: 'umother', title: __('Umother'), operate: 'LIKE'},
                        {field: 'intro', title: __('Intro'), operate: 'LIKE'},
                        {field: 'education', title: __('Education'), operate: 'LIKE'},
                        {field: 'major', title: __('Major'), operate: 'LIKE'},
                        {field: 'school', title: __('School'), operate: 'LIKE'},
                        {field: 'history', title: __('History'), operate: 'LIKE'},
                        {field: 'arttime', title: __('Arttime'), operate: 'LIKE'},
                        {field: 'artdirection', title: __('Artdirection'), operate: 'LIKE'},
                        {field: 'artsocial', title: __('Artsocial'), operate: 'LIKE'},
                        {field: 'ability', title: __('Ability'), operate: 'LIKE'},
                        {field: 'ability2', title: __('Ability2'), operate: 'LIKE'},
                        {field: 'img0', title: __('Img0'), operate: 'LIKE'},
                        {field: 'img1', title: __('Img1'), operate: 'LIKE'},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});